(function() {
  var __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

  this.AdminResponseCreateView = (function(_super) {

    __extends(AdminResponseCreateView, _super);

    function AdminResponseCreateView() {
      return AdminResponseCreateView.__super__.constructor.apply(this, arguments);
    }

    AdminResponseCreateView.prototype.el = $('#content');

    AdminResponseCreateView.prototype.initialize = function() {
      return AdminResponseCreateView.__super__.initialize.apply(this, arguments);
    };

    AdminResponseCreateView.prototype.render = function() {
      var _this = this;
      return this.GetTemplate(SiteMap.Admin.Responses.CreateTemplate, function(compiledTemplate) {
        $(_this.el).html(compiledTemplate(_this.model.toJSON()));
        $("#UserId").combobox({
          source: SiteMap.Admin.Shared.GetUsers,
          isDynamic: true
        });
        $('#BookId').combobox({
          source: SiteMap.Admin.Shared.GetBooks,
          isDynamic: true
        });
        return $("#DateOfPublish").datepicker();
      });
    };

    AdminResponseCreateView.prototype.events = {
      "click .buttons>button.save": "save",
      "click .buttons>button.cancel": "cancel"
    };

    AdminResponseCreateView.prototype.save = function(e) {
      var data,
        _this = this;
      e.preventDefault();
      Loading.Start();
      Messages.WriteMessage('Creating response.');
      data = $(this.el).find("form.general").serialize();
      return $.post(SiteMap.Admin.Responses.Create, data, function(response) {
        if (response.SuccessMessage !== null && response.SuccessMessage.length > 0) {
          Messages.WriteSuccessMessage(response.SuccessMessage);
          return _this.Navigate(SiteMap.Admin.Responses.Listing, true);
        } else {
          Messages.WriteErrors(response.Errors);
          return Loading.Stop();
        }
      });
    };

    AdminResponseCreateView.prototype.cancel = function(e) {
      e.preventDefault();
      Loading.Start();
      Messages.Clear();
      return this.Navigate(SiteMap.Admin.Responses.Listing, true);
    };

    return AdminResponseCreateView;

  })(CustomView);

}).call(this);
